package com.kevin.handler;

import com.kevin.codec.RpcDecoder;
import com.kevin.codec.RpcEncoder;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

public class RpcServerInitializer extends ChannelInitializer {
    @Override
    protected void initChannel(Channel channel) throws Exception {
        channel.pipeline().addLast(
                new LengthFieldBasedFrameDecoder(
                        Integer.MAX_VALUE,
                        12,
                        4)
                ).addLast(new RpcDecoder())
                .addLast(new RpcEncoder())
                .addLast(new RpcServerHandler());
    }
}
